﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using CMP.ERP.Model;
using CMP.ERP.Helper;

namespace CMP.ERP.DAL
{
    public class ExpressCompanyDAL
    {
        /// <summary>
        /// 实例化SQLHelper对象
        /// </summary>
        SQLHelper p = new SQLHelper();
        /// <summary>
        /// 显示快递公司信息
        /// </summary>
        /// <returns></returns>
        public DataTable ExpressCompanyShow()
        {
            string sql = "select Express_Company_Id,Express_Company_Name,Express_Company_Charges,Express_Company_Address,Express_Company_Phone from ExpressCompany";
            return p.ExecDataTable(sql);
        }
        /// <summary>
        /// 添加快递公司信息
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public int AddExpressCompany(ExpressCompany e)
        {
            string sql = string.Format("insert into ExpressCompany(Express_Company_Name,Express_Company_Charges,Express_Company_Address,Express_Company_Phone) values('{0}','{1}','{2}','{3}')", e.Express_Company_Name, e.Express_Company_Charges, e.Express_Company_Address, e.Express_Company_Phone);
            return p.ExecNonquery(sql);
        }
        /// <summary>
        /// 根据快递编码删除快递公司信息
        /// </summary>
        /// <param name="Express_Company_Id">快递编码</param>
        /// <returns></returns>
        public int DelExpressCompany(int Express_Company_Id)
        {
            string sql = string.Format("delete from ExpressCompany where Express_Company_Id='{0}'", Express_Company_Id);
            return p.ExecNonquery(sql);
        }
        /// <summary>
        /// 根据快递编码查询快递公司信息
        /// </summary>
        /// <param name="Express_Company_Id">快递编码</param>
        /// <returns></returns>
        public DataTable GetExpressCompany(int Express_Company_Id)
        {
            string sql = string.Format("select Express_Company_Id,Express_Company_Name,Express_Company_Charges,Express_Company_Address,Express_Company_Phone from ExpressCompany where Express_Company_Id='{0}'", Express_Company_Id);
            return p.ExecDataTable(sql);
        }
        /// <summary>
        /// 修改快递公司信息
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public int UpdExpressCompany(ExpressCompany e)
        {
            string sql = string.Format("update ExpressCompany set Express_Company_Name='{0}',Express_Company_Charges='{1}',Express_Company_Address='{2}',Express_Company_Phone='{3}' where Express_Company_Id='{4}'",e.Express_Company_Name,e.Express_Company_Charges,e.Express_Company_Address,e.Express_Company_Phone,e.Express_Company_Id);
            return p.ExecNonquery(sql);
        }
        /// <summary>
        /// 根据快递公司名称查询信息
        /// </summary>
        /// <param name="Express_Company_Name">快递公司名称</param>
        /// <returns></returns>
        public DataTable SelExpressCompany(string Express_Company_Name)
        {
            string sql = string.Format("select Express_Company_Id,Express_Company_Name,Express_Company_Charges,Express_Company_Address,Express_Company_Phone from ExpressCompany where Express_Company_Name like '%{0}%'", Express_Company_Name);
            return p.ExecDataTable(sql);
        }
    }
}
